import { storageCache } from './storage-cache'

/* 访问TOKEN BELOW */
const TOKEN_KEY = 'admin_token'
export function getToken() {
  return storageCache.getItem(TOKEN_KEY)
}
export function getTokenTTL() {
  return storageCache.getItemTTL(TOKEN_KEY)
}
export function setToken(token, age = 7200) {
  return storageCache.setItem(TOKEN_KEY, token, age)
}
export function removeToken() {
  return storageCache.removeItem(TOKEN_KEY)
}
/* 访问TOKEN ABOVE */

/* 用户信息 BELOW */
const USER_KEY = 'admin_user'
export function getUser() {
  return storageCache.getItem(USER_KEY)
}
export function setUser(user, age = 7200) {
  return storageCache.setItem(USER_KEY, user, age)
}
export function removeUser() {
  return storageCache.removeItem(USER_KEY)
}
/* 用户信息 ABOVE */

/* 刷新用的TOKEN BELOW */
const REFRESH_KEY = 'refresh_token'
export function getRefreshToken() {
  return storageCache.getItem(REFRESH_KEY)
}
export function setRefreshToken(token, age = 7200) {
  return storageCache.setItem(REFRESH_KEY, token, age)
}
export function removeRefreshToken() {
  return storageCache.removeItem(REFRESH_KEY)
}
/* 刷新用的TOKEN ABOVE */
